#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;
bool vis[N];
int f[N];
int start, two;
int n;
bool flag = false;

// 初始化并查集
void init() {
    for (int i = 1; i <= n; ++i) {
        f[i] = i;
    }
}

int Find(int x) {
    return f[x] = f[x] == x ? x : Find(f[x]);
}

void Union(int x, int y) {
    f[y] = f[x];
}

void dfs(int k, vector<vector<int>>& edge) {
    if (flag) {
        return;
    }

    if (k == two) {
        for (int i = 1; i <= n; ++i) {
            if (vis[i]) {
                cout << i << " ";
            }
        }
        flag = true;
        return;
    }

    for (int i = 0; i < edge[k].size(); ++i) {
        int next = edge[k][i];
        if (vis[next] != true) {
            vis[next] = true;
            dfs(next, edge);
            if (flag) return ;
            vis[next] = false;
        }
    }
}

int main() {
    cin >> n;

    init();
    vector<vector<int>> edge(n + 1, vector<int>());

    for (int i = 1; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        int x = Find(a);
        int y = Find(b);

        if (x != y) {
            edge[a].push_back(b);
            edge[b].push_back(a);
            Union(x, y);
        } else {
            start = a;
            two = b;
            break;
        }
    }

    vis[start] = true;
    dfs(start, edge);
    return 0;
}